<template>
    <div class="nav">
        <div class="nav-item" v-for="(item,index) in navList" :key="index" @click="toLink(item.id,item.link,index)" >
            <img :src="item.icon" alt="">
            <span>{{item.name}}</span>
        </div>
    </div>
</template>

<script>
// type==1 首页
// type==2 课程 
export default {
    props: ['navList',"type"],
    methods:{
        toLink(id,url,index){
            let Type=this.type;
            console.log(Type)
            if(Type==1){
                if(index==3){
                    wx.getStorage({
                        key: 'coordinate',
                        success: (result) => {
                            mpvue.navigateTo({url});
                        },
                        fail: () => {
                            wx.showModal({
                                title: '提示',
                                content: '您的位置信息未获取',
                                showCancel: true,
                                cancelText: '取消',
                                cancelColor: '#000000',
                                confirmText: '确定',
                                confirmColor: '#3CC51F',
                                success: (result) => {
                                    if (result.confirm) {
                                        // wx.getSetting()
                                    }
                                },
                                fail: () => {},
                                complete: () => {}
                            });
                              
                              
                        },
                        complete: () => {}
                    });
                      
                }else{
                    mpvue.navigateTo({url});
                }
                
                console.log(index)
            }else{
                
                let url="/pages/classList/main?cateId="+id+"&type="+Type
                console.log(url)
                mpvue.navigateTo({url})
            }
           
        }
    },
}

</script>

<style lang="scss">
   .nav {
       width: 100%;
       padding:8px 0;
       .nav-item{
           display: inline-block;
           text-align: center;
           margin-top:10px;
           img{
                width:40px;
                height:40px;
                display: block;
                margin: 0 auto;
           }
           span{
                font-size:12px;
                color:rgba(51,51,51,1);
                line-height:18px;
           }
       }
   }
</style>
